package com.chenglu.android.mine.member;

import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
import com.bumptech.glide.request.RequestOptions;
import com.chenglu.android.MainActivity;
import com.chenglu.android.R;
import com.chenglu.android.common.base.BaseActionBarActivity;
import com.chenglu.android.common.utils.GlideUtils;
import com.chenglu.android.common.utils.PxUtils;
import com.chenglu.android.common.utils.ToastUtils;
import com.chenglu.android.common.utils.Utils;
import com.chenglu.android.common.widget.RadiusImageView;
import com.chenglu.android.mine.bean.FansListBean;
import com.chenglu.android.mine.bean.MemberCenterBean;
import com.chenglu.android.mine.bean.PosterBean;
import com.chenglu.android.mine.bean.ReturnStringBean;
import com.chenglu.android.mine.member.mvp.contract.MemberContract;
import com.chenglu.android.mine.member.mvp.presenter.MemberPresenter;
import com.lxj.xpopup.XPopup;
import com.lxj.xpopup.animator.PopupAnimator;
import com.lxj.xpopup.core.CenterPopupView;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * @author: lyj
 * @Created: by Copyright 2023 6 Guangzhou Hongma Technology Co., Ltd. All rights reserved.
 * @Description：邀请粉丝
 */
public class InviteFansActivity extends BaseActionBarActivity<MemberPresenter> implements MemberContract.View {
    @BindView(R.id.iv_head_pic)
    RadiusImageView ivHeadPic;
    @BindView(R.id.tv_nickname)
    TextView tvNickname;
    @BindView(R.id.tv_level)
    TextView tvLevel;
    @BindView(R.id.iv_bg)
    ImageView ivBg;
    @BindView(R.id.iv_qr_code)
    ImageView ivQrCode;
    @BindView(R.id.tv_text_des)
    TextView tvTextDes;
    @BindView(R.id.tv_qr_clear)
    TextView tvQrClear;
    @BindView(R.id.tv_save_pic)
    TextView tvSavePic;
    @BindView(R.id.ll_loading_data)
    LinearLayout llLoadingData;
    @BindView(R.id.tv_no_data)
    TextView tvNoData;
    @BindView(R.id.ll_loading_no_data)
    LinearLayout llLoadingNoData;

    @Override
    protected int getLayoutId() {
        return R.layout.activity_invite_fans;
    }

    @Override
    protected void initView() {
        setCenterText("邀请粉丝");
        mPresenter = new MemberPresenter();
        mPresenter.attachView(this);


   ///server-system/wap/user/share/code/miniapp 邀请小程序二维码接口
        mPresenter.getPromotionPoster(getToken());
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // TODO: add setContentView(...) invocation
        ButterKnife.bind(this);
    }


    @Override
    public void getLevelDescriptions(ReturnStringBean bean) {

    }

    @Override
    public void getMemberCenterInfo(MemberCenterBean bean) {

    }

    @Override
    public void getFansPage(FansListBean bean) {

    }

    @Override
    public void getConsumerPage(FansListBean bean) {

    }

    @Override
    public void getPromotionPoster(PosterBean bean) {

        Glide.with(mContext).load(bean.getData().getPic()).into(ivBg);
    }

    @OnClick({R.id.tv_qr_clear, R.id.tv_save_pic,R.id.iv_qr_code})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.tv_qr_clear:
                showPicDialog();
                break;
            case R.id.tv_save_pic:

                break;
            case R.id.iv_qr_code:
                showPicDialog();
                break;
        }
    }

    private void showPicDialog() {
        CustomPopup customPopup = new CustomPopup(InviteFansActivity.this);
        new XPopup.Builder(InviteFansActivity.this)
                .asCustom(customPopup)
                .show();
    }


    //广告的接口在登录界面

    class CustomPopup extends CenterPopupView {
        //注意：自定义弹窗本质是一个自定义View，但是只需重写一个参数的构造，其他的不要重写，所有的自定义弹窗都是这样。
        public CustomPopup(@NonNull Context context) {
            super(context);
        }

        // 返回自定义弹窗的布局
        @Override
        protected int getImplLayoutId() {
            return R.layout.dialog_qr_code;
        }

        // 执行初始化操作，比如：findView，设置点击，或者任何你弹窗内的业务逻辑
        @Override
        protected void onCreate() {
            super.onCreate();

            ImageView dialogIvCode = findViewById(R.id.dialog_iv_code);


        }

        // 设置最大宽度，看需要而定，
        @Override
        protected int getMaxWidth() {
            return super.getMaxWidth();
        }

        // 设置最大高度，看需要而定
        @Override
        protected int getMaxHeight() {
            return super.getMaxHeight();
        }

        // 设置自定义动画器，看需要而定
        @Override
        protected PopupAnimator getPopupAnimator() {
            return super.getPopupAnimator();
        }

        /**
         * 弹窗的宽度，用来动态设定当前弹窗的宽度，受getMaxWidth()限制
         *
         * @return
         */
        protected int getPopupWidth() {
            return 0;
        }

        /**
         * 弹窗的高度，用来动态设定当前弹窗的高度，受getMaxHeight()限制
         *
         * @return
         */
        protected int getPopupHeight() {
            return 0;
        }




    }

}
